package com.xbai;

import com.xbai.bean.Person;
import com.xbai.config.MainConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

/**
 * @author xbai
 * @Date 2021/3/26
 */
public class MainTest {

    public static void main(String[] args) {
        /*ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans.xml");
        Person person = (Person) applicationContext.getBean("person");
        System.out.println(person);*/

        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);
        System.out.println(Arrays.toString(applicationContext.getBeanNamesForType(Person.class)));
        System.out.println(applicationContext.getBean("person"));
        System.out.println(applicationContext.getBean(Person.class));
    }
}
